<h2>
  {{ name }}
</h2>
<nz-collapse nzBordered="true">
  <nz-collapse-panel nzHeader="Options" [nzActive]="true">
    <form nzLayout="horizontal" nz-form>
      <nz-form-item>
        <nz-form-label>Rounds</nz-form-label>
        <nz-select
          [nzMaxTagCount]="6"
          name="Round"
          nzMode="multiple"
          nzPlaceHolder="--- Rounds ---"
          [(ngModel)]="listOfSelectedRounds"
        >
          <nz-option
            *ngFor="let option of listOfRounds"
            [nzLabel]="option.label"
            [nzValue]="option.value"
          ></nz-option>
        </nz-select>
      </nz-form-item>
      <nz-form-item>
        <nz-form-label>Values</nz-form-label>
        <nz-select
          class="valueSelect"
          name="Values"
          [nzMaxTagCount]="15"
          nzMode="multiple"
          nzPlaceHolder="--- Values ---"
          [(ngModel)]="listOfSelectedValues"
        >
          <nz-option-group nzLabel="Quantity">
            <nz-option [nzLabel]="getValueLabel('Quantity')" nzValue="Quantity">
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('quantityEnd')"
              nzValue="quantityEnd"
            >
            </nz-option>
          </nz-option-group>

          <nz-option-group nzLabel="Attacher">
            <nz-option [nzLabel]="getValueLabel('Kills')" nzValue="Kills">
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('OneShotDone')"
              nzValue="OneShotDone"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('explosionTriggered')"
              nzValue="explosionTriggered"
            >
            </nz-option>

            <nz-option
              [nzLabel]="getValueLabel('aliveTargets')"
              nzValue="aliveTargets"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('aliveTargetsShield')"
              nzValue="aliveTargetsShield"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('aliveTargetsNoShield')"
              nzValue="aliveTargetsNoShield"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('deathTargets')"
              nzValue="deathTargets"
            >
            </nz-option>

            <nz-option
              [nzLabel]="getValueLabel('damageDone')"
              nzValue="damageDone"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('armourDamageDone')"
              nzValue="armourDamageDone"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('shieldDamageDone')"
              nzValue="shieldDamageDone"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('threatAvg')"
              nzValue="threatAvg"
            >
            </nz-option>
            <nz-option [nzLabel]="getValueLabel('shipHit')" nzValue="shipHit">
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('defenceHit')"
              nzValue="defenceHit"
            >
            </nz-option>
          </nz-option-group>

          <nz-option-group nzLabel="Defender">
            <nz-option [nzLabel]="getValueLabel('Loses')" nzValue="Loses">
            </nz-option>
            <nz-option [nzLabel]="getValueLabel('Exploded')" nzValue="Exploded">
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('OneShotted')"
              nzValue="OneShotted"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('shotTaken')"
              nzValue="shotTaken"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('shotTakenDeath')"
              nzValue="shotTakenDeath"
            >
            </nz-option>

            <nz-option
              [nzLabel]="getValueLabel('damageTaken')"
              nzValue="damageTaken"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('armourDamageTaken')"
              nzValue="armourDamageTaken"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('shieldDamageTaken')"
              nzValue="shieldDamageTaken"
            >
            </nz-option>
            <nz-option
              [nzLabel]="getValueLabel('shieldRegenerationReceived')"
              nzValue="shieldRegenerationReceived"
            >
            </nz-option>
          </nz-option-group> </nz-select
      ></nz-form-item>
    </form>
  </nz-collapse-panel>
</nz-collapse>

<nz-table #statsTable [nzData]="stats" *ngIf="stats" nzShowPagination="false">
  <thead>
    <tr>
      <th rowspan="2">Name</th>
      <th
        [attr.colspan]="listOfSelectedValues.length"
        *ngFor="let round of listOfSelectedRounds"
      >
        {{ round > 5 ? "Total" : "Round " + round }}
      </th>
    </tr>
    <tr>
      <ng-container *ngFor="let option of listOfSelectedRounds">
        <th *ngFor="let value of listOfSelectedValues">
          {{ getValueLabel(value) }}
        </th>
      </ng-container>
    </tr>
  </thead>
  <tbody>
    <tr *ngFor="let data of statsTable.data" [class.bg-error]="!data.player">
      <td>{{ data.name }}</td>
      <ng-container *ngFor="let round of listOfSelectedRounds">
        <td *ngFor="let value of listOfSelectedValues">
          {{ getValue(data, round, value) | format }}
        </td>
      </ng-container>
    </tr>
  </tbody>
</nz-table>
